<%--
  Created by IntelliJ IDEA.
  User: 86181
  Date: 2022/11/18
  Time: 9:34
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>出库详情单</title>
</head>
<body>
<br>
        <div class="row">
            <div class="col-md-offset-11">
                <button class="btn btn-group" onclick="outoutpayshows()">退出</button>
            </div>
        </div>
        <br>
        <div class="container" style="width:1200px;height:650px;border:1px black solid">
            <input type="hidden" id="outboundregistraptionmodalidontab">
            <input type="hidden" id="outboundregistrationmodalpayIdontabs">
    <div class="row">
        <div class="col-md-offset-5"><h2><strong>出库单</strong></h2></div>
    </div>
    <br>
    <div class="row">
        <div class="col-md-6">
            <table>
                <tr>
                    <td>出库单编号:</td>
                    <td><input type="text" name="payId" id="outboundregistrationmodalpayIdontab" readonly style="width:230px;outline: none;border: none;"></td>
                </tr>
                <tr>
                    <td>出库理由:</td>
                    <td><input type="text"  id="outboundregistrationmodalreasonontab" readonly style="outline: none;border: none;"></td>
                </tr>
            </table>
        </div>
        <div class="col-md-6">
            <table>
                <tr>
                    <td>出库理由详情：</td>
                    <td><input id="outboundregistrationmodalreasonexactontab" type="text" readonly style="outline: none;border: none"></td>
                </tr>
            </table>
        </div>
        <br>
        <div style="height:45%;">
            <table id="outboundregistrationmodaltabontabtab"></table>
        </div>
        <br>
        <div class="row">
            <div class="col-md-6">
                <table>
                    <tr>
                        <td>应出库数量:</td>
                        <td><input type="text" name="amountSum" id="outboundregistrationmodalamountSumontab" readonly style="outline: none;border: none"></td>
                    </tr>
                    <tr>
                        <td>应出库总成本:</td>
                        <td><input type="text" id="outboundregistrationmodalcostPriceSumontab" readonly style="outline: none;border: none"></td>
                    </tr>
                    <tr>
                        <td>登记人:</td>
                        <td><input type="text" readonly name="register" id="outboundregistrationmodalregisterontab" required style="outline: none;border: none;border-bottom: 1px black dashed"></td>
                    </tr>
                    <tr>
                        <td>登记复核人:</td>
                        <td><input type="text" name="registrationreviewer" id="outboundregistrationmodalcheckertab" value="${username}" required style="outline: none;border: none;border-bottom: 1px black dashed"></td>
                    </tr>
                </table>
            </div>
            <div class="col-md-6">
                <table>
                    <tr>
                        <td>已出库数量:</td>
                        <td><input type="text" name="paidAmountSum"  id="outboundregistrationmodalpaidAmountSumontab" readonly style="outline: none;border: none"></td>
                    </tr>
                    <tr>
                        <td>已出库总成本:</td>
                        <td><input type="text" id="outboundregistrationmodalcostPriceSumsontab" readonly style="outline: none;border: none"></td>
                    </tr>
                    <tr>
                        <td>登记时间:</td>
                        <td><input type="text" name="registerTime" id="outboundregistrationmodalregisterTimeontab" readonly style="outline: none;border: none;"></td>
                    </tr>
                    <tr>
                        <td>登记复核时间:</td>
                        <td><input type="text" name="timeregistrationreviewer" id="outboundregistrationmodalcheckTimetab" readonly style="outline: none;border: none;"></td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
</div>
        <!--查询模态框-->
        <div class="modal fade"  tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel" id="outpeyshowalltabmodal">
            <div class="modal-dialog modal-lg">
                <div class="modal-content" id="outpeyshowalltabmodalson">

                </div>
            </div>
        </div>
        <script>
            //加载表格数据
            $(function () {
                $("#outboundregistrationmodaltabontabtab").bootstrapTable({
                    sortable: true,//是否显示排序
                    sortOrder: "aso",//排序方式
                    sidePagination:"server", //分页方式：client客户端分页，server服务端分页（*）
                    showColumns: true,//是否显示所有的列（选择显示的列）
                    showRefresh: true,//是否显示刷新按钮
                    minimumCountColumns: 2,//最少允许的列数
                    showToggle: true,//是否显示详细视图和列表视图的切换按钮
                    cardView: false,//是否显示详细视图
                    detailView: false,//是否显示父子表,
                    queryParams:function (params) {
                        var outboundregistrationmodal={
                            pagesize:params.limit,
                            pageno:(params.offset/params.limit)+1,
                            sort:params.sort,
                            sortOrder:params.sort,
                        }
                        return outboundregistrationmodal
                    },
                    columns:[
                        {
                            field:"",
                            title:"序号",
                            formatter:function (value,row,index) {
                                return Number(index)+1
                            }
                        },
                        {
                            field:"productId",
                            title:"产品编号",
                        },
                        {
                            field:"productName",
                            title:"产品名称",
                        },
                        {
                            field:"costPrice",
                            title:"成本价格",
                        },
                        {
                            field:"cell",
                            title:"当前库存",
                            formatter:function (value,row,index) {
                                return value.amount
                            }
                        },
                        {
                            field:"amount",
                            title:"应出库数量",
                        },
                        {
                            field:"warehousing",
                            title:"已出库数量",
                        },
                        /* {
                             field:"paidAmount",
                             title:"出库数量",
                         },*/
                        {
                            field:"paidAmount",
                            title:"本次出库数量",
                        },
                        {
                            field:"",
                            title:"查询",
                            formatter:function (value,row,index) {
                               return "<input type='button' value='查询' onclick='queryoutwaltabpayid("+row.productId+")'>"
                            }
                        },


                    ]
                })
                //获取值
                var payId='${param.payId}'
                $.post("queryByPayCellPayDetails.action",{"payId":payId},function (data) {
                    //出库编号
                    $("#outboundregistrationmodalpayIdontabs").val(data.payId)
                    if(data.payTag=="K002-1"){
                        $("#outboundregistrationmodalpayIdontab").css("color","green")
                        $("#outboundregistrationmodalpayIdontab").val(data.payId+"/完成")
                    }
                    if(data.payTag=="K002-2"){
                        $("#outboundregistrationmodalpayIdontab").css("color","goldenrod")
                        $("#outboundregistrationmodalpayIdontab").val(data.payId+"/等在登记")
                    }
                    if(data.payTag=="K002-3"){
                        $("#outboundregistrationmodalpayIdontab").css("color","goldenrod")
                        $("#outboundregistrationmodalpayIdontab").val(data.payId+"/等待审核")
                    }
                    //出库理由
                    var reasons="";
                    if(data.reason=="C002-1"){
                        reasons="生产领料"
                    }
                    if(data.reason=="C002-2"){
                        reasons="赠送"
                    }
                    if(data.reason=="C002-3"){
                        reasons="内部借领"
                    }
                    if(data.reason==" C002-4"){
                        reasons="其他借领"
                    }
                    $("#outboundregistrationmodalreasonontab").val(reasons)
                    //出库详情理由
                    $("#outboundregistrationmodalreasonexactontab").val(data.reasonexact)
                    //应出库数量
                    $("#outboundregistrationmodalamountSumontab").val(data.amountSum)
                    //应出库总成本
                    $("#outboundregistrationmodalcostPriceSumontab").val(data.costPriceSum)
                    //登记人
                    $("#outboundregistrationmodalregisterontab").val(data.register)
                    $("#outboundregistraptionmodalidontab").val(data.id)
                    //登记时间
                    $("#outboundregistrationmodalregisterTimeontab").val(data.registerTime)
                    //点击获取当前时间
                    $("#outboundregistrationmodalcheckTimetab").val(data.timeregistrationreviewer)
                    //登记复核人
                    $("#registrationreviewer").val(data.registrationreviewer)
                    //加载表格数据集
                    var arr=[]
                    var arrs=data.payDetails;
                    for(var i=0;i<arrs.length;i++){
                        arr.push(arrs[i])
                    }
                    //加载给表格
                    $("#outboundregistrationmodaltabontabtab").bootstrapTable("append",arr)
                    //获取值
                    var paydetalis=$("#outboundregistrationmodaltabontabtab").bootstrapTable("getData")
                    var i=0;
                    console.log(data.payDetails)
                    var nums=0;
                    $(paydetalis).each(function (index,item) {
                        i+=Number(item.warehousing);
                        nums+=i*data.payDetails[index].costPrice;
                    })
                    //已出库数量
                    $("#outboundregistrationmodalpaidAmountSumontab").val(i)
                    //已出库总成本
                    $("#outboundregistrationmodalcostPriceSumsontab").val(nums)
                },"json")
            })
            function outoutpayshows() {
                $("#tab1").addTabs("出库登记查询", "", "outpeyshowall.jsp","", true);
                $("#tab1").closeTabs("出库详情查询")
            }
            //查询
            function queryoutwaltabpayid(productId) {
                $("#outpeyshowalltabmodalson").load("outpeyshowalltabmodal.jsp",{"productId":productId,"id":$("#outboundregistraptionmodalidontab").val(),"payId":$("#outboundregistrationmodalpayIdontabs").val(),"tie": $("#outboundregistrationmodalcheckTimetab").val()})
                $("#outpeyshowalltabmodal").modal("show")
            }
        </script>
</body>
</html>
